package com.ehotting.edsta.reliability.controller;

import com.ehotting.eaf.core.domain.R;
import com.ehotting.eaf.core.web.controller.BaseController;
import com.ehotting.eaf.core.web.domain.AjaxResult;
import com.ehotting.edsta.common.log.annotation.Log;
import com.ehotting.edsta.common.log.enums.BusinessType;
import com.ehotting.edsta.mqbd.reliability.api.domain.SimulateDto;
import com.ehotting.edsta.mqbd.reliability.api.domain.SimulateResultDto;
import com.ehotting.edsta.reliability.service.ICommonService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(tags = "CommonController",description = "可靠性预计服务接口")
@RestController
@RequestMapping("/common")
public class CommonController extends BaseController {

    private final  static Logger logger = LoggerFactory.getLogger(CommonController.class);

    @Autowired
    private ICommonService commonService;

    /**
     *
     * @param simulateDto simutype 1-热学仿真，2-振动仿真
     * @param simulateDto filepath 仿真输入文件目录
     * @return
     */
    @Log(title = "多物理仿真（腾睿）", businessType = BusinessType.OTHER,isSaveResponseData = false)
    @ApiOperation("仿真接口")
    @PostMapping("/simulate")
    public R<SimulateResultDto> simulate(@RequestBody SimulateDto simulateDto){
        logger.info("Start simulate.");
        SimulateResultDto simulateResultDto = commonService.runAnsys(simulateDto);
        logger.info("Finish simulate.");
        return R.ok(simulateResultDto);
    }

    /**
     * @return
     */
    @PostMapping("/helloWorld")
    public AjaxResult simulate(){
        commonService.helloWorld();
        return AjaxResult.success();
    }


}
